package zjh_20230330;

import java.io.*;

public class Demo03 {
    public static void main(String[] args) {
        try (FileInputStream fileInputStream = new FileInputStream("D:\\kaifamiao\\io-text\\text1.txt");
             InputStreamReader inputStreamReader = new InputStreamReader(fileInputStream, "UTF-8");
             BufferedReader bufferedReader = new BufferedReader(inputStreamReader)) {
//            System.out.println("文件编码是gbk，用UTF-8读取会乱码哦~");
            System.out.println("UTF-8解读");
            String s;
            while ((s = bufferedReader.readLine()) != null){
                System.out.println(s);
            }
            System.out.println("我好了~");
//            System.out.println("不出意外，我会乱码~");
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
}
